/**
 * @date 3:18:55 PM
 * EducationGroup.java
 * Administrator
 * TODO
 */
package com.qs.education.bean.entity;

import java.util.ArrayList;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import lombok.Getter;
import lombok.Setter;

/**
 * @class EducationGroup
 * @author Warren
 * @description
 * @date Nov 7, 2018
 */
@Entity
@Table(name = "education_group")
@Getter
@Setter
public class EducationGroup {
	@Id
	@Column(name = "id", unique = true, nullable = false)
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long id;
	private String name;
	private String description;
	private String headImage;
	@Column(name = "create_time")
	private String createTime;

	@ManyToMany
	@JoinTable(name = "education_teacher_group", joinColumns = {
			@JoinColumn(name = "group_id", referencedColumnName = "id") }, inverseJoinColumns = {
					@JoinColumn(name = "teacher_id", referencedColumnName = "id") })
	@JsonIgnoreProperties(value = { "group", "school", "groups", "subject", "homeWorkList" })
	private List<EducationTeacher> teachers = new ArrayList<EducationTeacher>();

	@ManyToMany(fetch = FetchType.EAGER)
	@JoinTable(name = "education_student_group", joinColumns = {
			@JoinColumn(name = "group_id", referencedColumnName = "id") }, inverseJoinColumns = {
					@JoinColumn(name = "student_id", referencedColumnName = "id") })
	@JsonIgnoreProperties(value = { "school", "groups", "grade", "clazz", "password" })
	private List<EducationStudent> students = new ArrayList<EducationStudent>();

	@ManyToOne
	@JoinColumn(name = "teacher_id")
	@JsonIgnoreProperties(value = { "group", "groups", "homeWorkList" })
	private EducationTeacher teacher;

	@OneToOne
	@JoinColumn(name = "grade_id")
	private EducationGrade grade;

	@OneToOne
	@JoinColumn(name = "class_id")
	private EducationClass clazz;

	@OneToMany
	@JoinColumn(name = "group_id")
	@JsonIgnoreProperties(value = { "group", "teacher", "homeWorkQuestionList" })
	private List<EducationHomeWork> homeWorkList;

	@OneToMany
	@JoinColumn(name = "group_id")
	@JsonIgnoreProperties(value = { "teacher", "group" })
	private List<EducationTeacherMessage> messages;
}
